import os

##序列转视频
# ffmpeg=os.getenv('FFMPEG_BINARY')
# print(ffmpeg)
# images_path=r'D:\Q\TimeLineOut\myFirstProject\imgs'
# images=os.path.join(images_path,'%d.png')
# fps=25
#
# mp4=os.path.join(os.path.dirname(__file__),'a.mp4')
# cmd='ffmpeg -f image2 -i {} -y -vcodec libx264 -r {}  {}'.format(images,fps,mp4)
#
# os.popen(cmd)


##视频加音频

mp4_path=r'D:\Q\TimeLineOut\myFirstProject\temp'
mp4=os.path.join(mp4_path,'temp.mp4')
mp3_path=r'D:\Q\TimeLineOut\myFirstProject\temp'
mp3=os.path.join(mp3_path,'temp_audio.mp3')
out_video_path=r'D:\pythonOUT\CGAI\ImageTimeLine\test'
out_video=os.path.join(out_video_path,'ff.mp4')
# cmd='ffmpeg -i {} -i {}  -y  {}' .format(mp3,mp4,out_video) # -t 7.1
# os.popen(cmd)
cmd='ffmpeg -i {} -i {} -filter_complex [1:a]aloop=loop=-1:size=2e+09[out]; [out][0:a]amix -y  {}'.format(mp4,mp3,out_video)
# cmd='ffmpeg -i {} -i {} -y {}' .format(mp3,mp4,out_video) #[out][0:a]amix  混合背景声音
os.popen(cmd)